# 导包
import pymysql
# 创建连接
conn = pymysql.connect(host="192.168.1.75",
port=3306,
user="root",
password="xk@12580",
database="xiekang_yxcontrol")
# 获取游标
cursor = conn.cursor()
# 执行sql
sql = "SELECT * FROM t_disease_infectious_report WHERE RecordId < 5;"
cursor.execute(sql)
# cursor.execute("select version()")
# result = cursor.fetchone()
# print(type(result))
# print(len(result))
# print(result)
result = cursor.fetchmany(2)
print(type(result))
print(len(result))
print(result)
# 关闭游标
cursor.close()
# 关闭连接
conn.close()